import 'package:flutter_model_package/parse_base.dart';
import 'package:parse_server_sdk/parse_server_sdk.dart';

import 'TuitionOrderItem.dart';
import 'student.dart';
// import 'package:parse_server_sdk/parse_server_sdk.dart';

class TuitionOrder extends MSParseBase {
  TuitionOrder() : super("TuitionOrder");

  TuitionOrder.cloe() : this();

  @override
  TuitionOrder clone(Map<String, dynamic> map) =>
      TuitionOrder.cloe()..fromJson(map);

  QueryBuilder<TuitionOrderItem> items() =>
      QueryBuilder(TuitionOrderItem())..whereEqualTo("order", this);

  static QueryBuilder<TuitionOrder> forStudent(
          Student student, DateTime month) =>
      QueryBuilder(TuitionOrder())
        ..whereEqualTo("student", student)
        ..whereLessThanOrEqualTo(
            "orderFrom", new DateTime(month.year, month.month, 1))
        ..whereGreaterThanOrEqualsTo(
            "orderTo", new DateTime(month.year, month.month, 31));

  QueryBuilder<TuitionOrder> forStudentOrder(Student student) {
    return QueryBuilder(this)
      ..includeObject(["service.category", "student.branch"])
      ..whereEqualTo("student", student);
  }
}
